'use strict';
const requireEx = require('yi-require');
const ObjectID = require('mongodb').ObjectID;

const middleware = (req, res, next) => {
    let doc = req.body;
    //
    // let authInfo =  req.context||req.context.authInfo ;
    // if(!req.context || !req.context.authInfo){
    //     return res.err.unauthorized();
    // }
    // authInfo = authInfo.authInfo;
    //
    // doc.userId = ObjectID(authInfo._id);

    req.mongo.collection('order').updateOne({orderNo:doc.orderNo},{$set:{orderStatus:'待收货'}},(e0,r0)=>{
        if(e0) return res.err.unknownError(e0);
        next();
    });
};

module.exports = {
    open : false,
    middleware: middleware,
    description:'新增物流信息',
    handler: requireEx('yi-restful').c('transport',[])
};
